home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / doc / makeproto.doc < prev    next >
Text File  |  1994-02-13  |  2KB  |  73 lines

  1.  
  2. makeproto/makeproto                        makeproto/makeproto
  3.  
  4.                 MAKEPROTO.DOC
  5.  
  6.                 GENERAING PROTOTYPES
  7.  
  8.     MAKEPROTO [-o outputfile] srcfile srcfile srcfile...
  9.  
  10.  
  11.     This has nothing to do with Lattice's prototype generation options.
  12.     With a little more work, using MakeProto to mesh multiple source
  13.     modules together is clean and easy to use.
  14.  
  15.     makeproto is not a magic program.  In fact, source is available
  16.     in DCC2:DUTIL/MAKEPROTO.C .  All it does is scan the specified
  17.     source files for 'Prototype' lines and write them to the specified
  18.     output file.  A good example of the use of MAKEPROTO is the DME SOURCE
  19.     (DCC3:DME.LZH).  NOTE: use -x -r when extracting DME.LZH .  The DME
  20.     source also includes a good example of a DMakefile.
  21.  
  22.     Basically, each file should include a .H file, lets call it DEFS.H .
  23.     DEFS.H contains the following two defines:
  24.  
  25.     #define Prototype   extern
  26.     #define Local        static
  27.  
  28.     DEFS.H also, at the end, contains a line similar to this:
  29.  
  30.     #include "prog-protos.h"
  31.  
  32.     What you want to do is set up a dependancy in your DMakefile, Makefile,
  33.     or whatever such that whenever any source files change, MAKEPROTO is
  34.     run over all source files to create a new version of "prog-protos.h".
  35.     MAKEPROTO simply extracts 'Prototype' lines from the source files.
  36.  
  37.     Thus, for each source file, you supply a list of Prototype and Local
  38.     lines at the beginning of the file which describe the functions that
  39.     appear later on and prototypes them for other source modules;
  40.  
  41.     --------------------    FOO.C --------------------
  42.  
  43.     #include "defs.h"
  44.  
  45.     Prototype int MYGlobalRoutine(char *);
  46.  
  47.     Local void SomeForwardRefdRoutine(void);
  48.  
  49.     int
  50.     MyGlobalRoutine(str)
  51.     char *str;
  52.     {
  53.     SomeForwardRefdRoutine();
  54.     return(str + 1);
  55.     }
  56.  
  57.     Local void
  58.     SomeForwardRefdRoutine(void)
  59.     {
  60.     /* whatever */
  61.     }
  62.  
  63.     --------------------
  64.  
  65.  
  66.     The system is clean because prototypes for routines are defined in
  67.     the same source file as the routines themselves.  To generate a
  68.     prototype file for the above source module and, say, a few others,
  69.     the sequence is:
  70.  
  71.     1> makeproto -o prog-protos.h foo.c main.c x.c bar.c fubar.c
  72.  
  73.